package com.phantasy.scene.sceneUnit
{
	import com.phantasy.proto.p_map_role;
	import com.phantasy.scene.sceneKit.RoleNameItem;
	import com.phantasy.scene.sceneKit.RoleNames;
	import com.phantasy.scene.sceneManager.LoopManager;
	import com.phantasy.scene.sceneUnit.baseUnit.things.avatar.Avatar;
	import com.phantasy.scene.tile.Pt;
	
	import flash.display.Sprite;
	import flash.geom.Point;
	
	public class MyRole extends Animal implements IRole
	{
		public var finalPt:Pt;
		public var underControlID:int;
		private var attackAbledID:int;
		public var underControl:Boolean = true;
		public var attackAbled:Boolean = true;
		
		private var attackSpeed:int;
		private var _pvo:p_map_role;
		private var attributeChangeEffect:Sprite;
		private var names:RoleNames;
		private var nowSlice:Point;
		
		public function MyRole()
		{
			super();
		}
		
		/**
		 *重置 
		 * @param pVo
		 * 
		 */		
		public function reset(pVo:p_map_role):void
		{
			this.isDead = (pVo.state == RoleActState.DEAD);
			this.curState = pVo.state;
			finalPt=null;
			LoopManager.clearTimeout(this.underControlID);
			LoopManager.clearTimeout(this.attackAbledID);
			this.underControl = true;
			this.attackAbled = true;
			this.id = pVo.role_id;
			this.attackSpeed = 900;
			speed = pVo.move_speed;
			this._pvo = pVo;
			if(avatar==null){
				super.initSkin(pVo.skin,pVo.category,pVo.sex);
			}else{
				avatar.addEventListener(Avatar.BODY_COMPLETE, this.onBodyComplete);
				avatar.updataSkin(this._pvo.skin);
			}
			
			if(!attributeChangeEffect){
				this.attributeChangeEffect = new Sprite();
				this.addChild(this.attributeChangeEffect);
			}
			
			if(!names){
				this.names = new RoleNames(pVo);
				this.addChild(this.names);
			}
			
			doNameJob();
			createBuff(pVo.state_buffs);
			checkHasFollowNPC();
			nowSlice = slice;
			LoopManager.addToFrame(this, this.loop);
		}
		
		public function doNameJob():void
		{
			names.reset(this._pvo);
			names.doMouseOut();
		}
		
		public function createBuff(buffList:Array):void
		{
			
		}
		
		public function checkHasFollowNPC():void
		{
			
		}
		
		public function doHook(_arg1:Boolean):void
		{
		}
		
		public function set pvo(_arg1:p_map_role):void
		{
		}
		
		public function get pvo():p_map_role
		{
			return null;
		}
		
		override protected function loop():void
		{
			super.loop();
			this.checkAutoSit();
		}
		
		override public function die():void
		{
			super.die();
		}
		
		private function checkAutoSit():void
		{
			
		}
	}
}